import { HttpMethod } from '@/services/types';
import { request } from '@/api/request';

/**
 * GET /search 搜索列表
 * @param options
 */
export async function resSearch(
  options?: { [key: string]: any },
) {
  return request<API.SearchStruct[]>('/search', {
    method: HttpMethod.GET,
    ...(options || {}),
  });
}

/**
 * Delete /search/:id 删除搜索
 * @param id
 * @param options
 */
export async function resDeleteSearch(
  id: number,
  options?: { [key: string]: any },
) {
  return request<R<null>>('/search/' + id, {
    method: HttpMethod.DELETE,
    ...(options || {}),
  });
}

/**
 * POST /search 添加搜索
 * @param params
 * @param options
 */
export async function resAddSearch(
  params: API.SearchParams,
  options?: { [key: string]: any },
) {
  return request<API.SearchStruct>('/search', {
    method: HttpMethod.POST,
    data: params,
    ...(options || {}),
  });
}

/**
 * GET /search/hot 获取热搜
 * @param options
 */
export async function resSearchHot(
  options?: { [key: string]: any },
) {
  return request<API.SearchStruct[]>('/search/hot', {
    method: HttpMethod.GET,
    ...(options || {}),
  });
}

